home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 1994, by WATCOM International Inc. All rights %
- % reserved. No part of this software may be reproduced or %
- % used in any form or by any means - graphic, electronic or %
- % mechanical, including photocopying, recording, taping or %
- % information storage and retrieval systems - except with the %
- % written permission of WATCOM International Inc. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- /*************************************************************************
- *
- * WImageList -- Wrapper for the Windows 95 Image List control.
- *
- *************************************************************************/
-
- #ifndef _WIMAGELIST_HPP_INCLUDED
- #define _WIMAGELIST_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WIMGLIST_HPP_INCLUDED
- # include "wimglist.hpp"
- #endif
- #ifndef _WOBJECT_HPP_INCLUDED
- # include "wobject.hpp"
- #endif
- #ifndef _WRESID_HPP_INCLUDED
- # include "wresid.hpp"
- #endif
- #ifndef _WPOINT_HPP_INCLUDED
- # include "wpoint.hpp"
- #endif
- #ifndef _WRECT_HPP_INCLUDED
- # include "wrect.hpp"
- #endif
- #ifndef _WCANVAS_HPP_INCLUDED
- # include "wcanvas.hpp"
- #endif
- #ifndef _WBITMAP_HPP_INCLUDED
- # include "wbitmap.hpp"
- #endif
-
- class WIcon;
- class WColor;
- class WWindow;
- class WImageListReference;
-
- enum WILDrawingStyle {
- WILDSNormal = 0x0000,
- WILDSTransparent = 0x0001,
- WILDSFocus = 0x0002,
- WILDSSelected = 0x0004,
- WILDSMask = 0x0010,
- WILDSImage = 0x0020,
-
- WILDSBlend25 = WILDSFocus,
- WILDSBlend50 = WILDSSelected
- };
-
- struct WImageInformation {
- WBitmap image;
- WBitmap mask;
- WRect imageBounds;
- };
-
- #ifndef _WIN16
- #undef ExtractIcon
- #if defined( _UNICODE )
- #define ExtractIcon ExtractIconW
- #else
- #define ExtractIcon ExtractIconA
- #endif
- #endif
-
- #define WILStyleDefault (0x0000)
- #define WILStyleMasked (0x0001)
-
- #define WIIndexToOverlayMask(i) ((i)<<8)
-
- class WCMCLASS WImageList : public WObject {
- WDeclareSubclass( WImageList, WObject );
-
- public:
-
- /**********************************************************
- * Constructors and destructors
- *********************************************************/
-
- // Constructors
- //
-
- WImageList( const WResourceID & id, WInt width, WInt grow,
- const WColor & maskColor, WModuleHandle module=_ApplicationModule );
- WImageList( WInt width, WInt height, WULong flags=WILStyleMasked,
- WInt initial=10, WInt grow=5 );
- WImageList( const WImageList & source, WBool makeCopy=FALSE );
- WImageList( WImageListHandle handle=NULLHIMAGELIST,
- WBool destroyImageList=TRUE );
-
- ~WImageList();
-
- /**********************************************************
- * Operators
- *********************************************************/
-
- WImageList & operator=( const WImageList & );
-
- int operator==( const WImageList & ) const;
- int operator!=( const WImageList & ) const;
-
- /**********************************************************
- * Properties
- *********************************************************/
-
- // BackColor
- //
- // Gets/sets the background color of the image list.
-
- WColor GetBackColor() const;
- WBool SetBackColor( const WColor & color );
-
- // Count
- //
- // Return the number of images in the list.
-
- WInt GetCount() const;
-
- // DragImageList
- //
- // Return the (temporary) image list used for dragging.
- // A valid image list is only returned after a call to
- // BeginDrag, and the image list is invalid after EndDrag.
- // A null image list is returned otherwise.
-
- WImageList GetDragImageList() const;
-
- // DragOffset
- //
- // Return the offset of the drag image relative to the current
- // drag position. Only valid between calls to BeginDrag
- // and EndDrag.
-
- WPoint GetDragOffset() const;
-
- // DragPosition
- //
- // Return the current drag position. Only valid between
- // calls to BeginDrag and EndDrag.
-
- WPoint GetDragPosition() const;
-
- // Handle
- //
- // Return the image list handle.
-
- WImageListHandle GetHandle() const;
-
- // Height
- //
- // Return the height in pixels of a single image in the
- // image list. Setting the height clears the list of all
- // images.
-
- WInt GetHeight() const;
- WBool SetHeight( WInt height );
-
- // Width
- //
- // Return the width in pixels of a single image in the
- // image list. Setting the width clears the list of all
- // images.
-
- WInt GetWidth() const;
- WBool SetWidth( WInt width );
-
- /**********************************************************
- * Methods
- *********************************************************/
-
- // Add
- //
- // Adds a bitmap or icon to the image list.
- // Returns the index of the new item, or -1 on error.
-
- WLong Add( const WIcon & icon );
- WLong Add( const WBitmap & nonMaskedImage );
- WLong Add( const WBitmap & nonMaskedImage,
- const WBitmap & maskedImage );
- WLong Add( const WBitmap & image, const WColor & color );
-
- // BeginDrag
- //
- // Begin a drag operation. An image is prepared for use
- // in drawing as a cursor. If no hotspot
- // is given, default to 0, 0.
-
- WBool BeginDrag( WLong imageIndex, const WPoint *hotspot=NULL ) const;
-
- // Clear
- //
- // Destroy or free the imagelist.
-
- WBool Clear( WBool destroy=TRUE );
-
- // Create
-
- WBool Create( const WResourceID & id, WInt width, WInt grow,
- const WColor & maskColor, WModuleHandle module=_ApplicationModule );
- WBool Create( WInt width, WInt height, WULong flags=WILStyleMasked,
- WInt initial=10, WInt grow=5 );
- WBool Create( const WImageList & source, WBool makeCopy=FALSE );
- WBool Create( WImageListHandle handle=NULLHIMAGELIST,
- WBool destroyIt=TRUE );
-
- // Delete
-
- WBool Delete( WLong imageIndex );
-
- // DeleteAll
- //
- // Deletes all the images from the imagelist, but does not
- // destroy or free the imagelist itself. (Use Clear for that.)
-
- WBool DeleteAll();
-
- // DragEnter
- //
- // Use to actually start drawing the drag image. If no
- // position is given, default to current mouse position.
- // If no object/window is given, default to desktop.
- // Fails if BeginDrag was not called first. Mouse coordinates
- // can be either absolute or relative to the window.
-
- WBool DragEnter( WWindowHandle window=NULLHWND,
- const WPoint * atPosition=NULL,
- WBool absolutePosition=TRUE ) const;
- WBool DragEnter( const WWindow * inWindow,
- const WPoint * atPosition=NULL,
- WBool absolutePosition=TRUE ) const;
-
- // DragLeave
- //
- // Use to unlock the window and hide the drag image. If no
- // window specified, unlocks what was locked by DragEnter.
-
- WBool DragLeave( WWindowHandle window=NULLHWND ) const;
- WBool DragLeave( const WWindow * window ) const;
-
- // DragMove
- //
- // Use to move the cursor while dragging. Returns FALSE
- // if BeginDrag and DragEnter were not called first. If
- // no position is given, uses current mouse position.
-
- WBool DragMove( const WPoint * atPostion=NULL,
- WBool absolutePosition=TRUE ) const;
-
- // DragShow
- //
- // Use when dragging to show/hide the drag image.
- // Returns FALSE if BeginDrag was not called.
-
- WBool DragShow( WBool showImage ) const;
-
- // Draw
- //
- // Draw an image from the image list into the given port
- // at the given position.
-
- WBool Draw( WLong imageIndex, const WCanvas & port,
- const WPoint & atPosition,
- WILDrawingStyle style=WILDSNormal ) const;
- WBool Draw( WLong imageIndex, const WCanvas & port,
- const WPoint & atPosition,
- const WSize & size,
- const WColor & backColor, const WColor & foreColor,
- WILDrawingStyle style ) const;
-
- // EndDrag
- //
- // Use to end a dragging operation. Calls DragLeave if
- // necessary.
-
- WBool EndDrag() const;
-
- // ExtractIcon
- //
- // Create an icon out of an imagelist item.
-
- WIcon ExtractIcon( WLong imageIndex,
- WILDrawingStyle style=WILDSNormal ) const;
-
- // ExtractImageInformation
- //
- // Retrieve the image information for a specific image.
- // Fills in the WImageInformation structure.
-
- WBool ExtractImageInformation( WLong imageIndex,
- WImageInformation *info ) const;
-
- // Merge
- //
- // Creates a new image list by merging together two images
- // from existing lists. The second image is drawn
- // transparently over the first and can also be offset.
-
- WImageList Merge( const WImageList & list1, WLong index1,
- const WImageList & list2, WLong index2,
- WInt dx=0, WInt dy=0 ) const;
-
- // Overlay
- //
- // Define an image as an overlay image. Up to four images
- // in a list can be defined as overlay images.
-
- WBool Overlay( WLong imageIndex, WLong whichOverlay );
-
- // Replace
- //
- // Replace an image with another.
-
- WBool Replace( WLong imageIndex, const WBitmap & newImage,
- const WBitmap & newMask=WBitmap::GetNullBitmap() );
- WBool Replace( WLong imageIndex, const WIcon & newIcon );
-
- /**********************************************************
- * Other
- *********************************************************/
-
- WLong AddIcon( const WIcon & icon );
- WLong AddBitmap( const WBitmap & nonMasked );
- WLong AddBitmap( const WBitmap & nonMasked, const WBitmap & mask );
- WLong AddMaskedBitmap( const WBitmap & nonMasked, const WColor & c );
-
- /**********************************************************
- * Data members
- *********************************************************/
-
- private:
- WImageListReference *_ref;
- };
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WIMAGELIST_HPP_INCLUDED
-